<?php
class Pages extends CI_Controller {
	
	public function __construct()
	{
		parent::__construct();
		$this->load->helper('url');
		$this->load->library('user_agent');
		$this->load->model('pages_model');
	}

	public function index($page='home')
	{
		$rs = $this->pages_model->get_pages($page);
		$data['page'] = $rs->row_array();
		if (empty($data['page']))
		{
		show_404();
		}
	
	$data['page_title'] = ucfirst($data['page']['page_name']); // Capitalize the first letter
	$is_mobile = $this->agent->is_mobile();
	//$is_mobile = true; //uncomment for mobile version
	
	if (!$is_mobile) {
		$this->load->view('web/templates/header', $data);
		$this->load->view('web/'.$page, $data);
		$this->load->view('web/templates/footer', $data);
	} else {
		$this->load->view('mobile/templates/header', $data);
		$this->load->view('mobile/'.$page, $data);
		$this->load->view('mobile/templates/footer', $data);
	}
	
	}
	
	public function load_static_page($page_name)
	{
	$data['page_title'] = ucfirst($page_name); // Capitalize the first letter
	$is_mobile = $this->agent->is_mobile();
	//$is_mobile = true; //uncomment for mobile version
	if ($is_mobile) {
		if ( ! file_exists('application/views/mobile/'.$page_name.'.php'))
		{
			// Whoops, we don't have a page for that!
			show_404();
		}
		$this->load->view('mobile/templates/header', $data);
		$this->load->view('mobile/'.$page_name, $data);
		$this->load->view('mobile/templates/footer', $data);
	} else {
		if ( ! file_exists('application/views/web/'.$page_name.'.php'))
		{
			// Whoops, we don't have a page for that!
			show_404();
		}
		$this->load->view('web/templates/header', $data);
		$this->load->view('web/'.$page_name, $data);
		$this->load->view('web/templates/footer', $data);
	}
	
	}
}
